package bch.maven.plugin.guava;

import com.google.common.collect.EnumBiMap;

public class EnumBiMapExample {
    enum Role { ADMIN, USER, GUEST }
    enum Code { A, B, C }

    public static void main(String[] args) {
        EnumBiMap<Role, Code> roleCodeMap = EnumBiMap.create(Role.class, Code.class);
        roleCodeMap.put(Role.ADMIN, Code.A);
        roleCodeMap.put(Role.USER, Code.B);
        roleCodeMap.put(Role.GUEST, Code.C);

        System.out.println("ADMIN 对应代码：" + roleCodeMap.get(Role.ADMIN)); // A
        System.out.println("反查 Code.B 对应角色：" + roleCodeMap.inverse().get(Code.B)); // USER
    }
}
